package com.jrx.anytxn.transaction.mapper.ext;

import com.jrx.anytxn.transaction.entity.TlPaymentMapping;
import com.jrx.anytxn.transaction.mapper.base.TlPaymentMappingMapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

public interface ExtTlPaymentMappingMapper extends TlPaymentMappingMapper {

    /**
     * 批量插入还款流水预订单映射
     *
     * @param paymentMappings 还款流水预订单映射信息
     * @return
     */
    int batchInsert(List<TlPaymentMapping> paymentMappings);

    /**
     * 根据还款流水号及客户id查询还款流水与订单映射信息
     *
     * @param paymentSeq 还款流水好
     * @param customerId 客户id
     * @param tenantId 租户id
     * @return
     */
    List<TlPaymentMapping> selectByPaymentSeqAndCustomerId(@Param(value="paymentSeq") String paymentSeq,
                                                     @Param(value="customerId") String customerId,
                                                     @Param(value="tenantId") String tenantId);

    /**
     * 根据还订单号及客户id查询还款流水与订单映射信息
     *
     * @param loanId 订单号
     * @param customerId 客户id
     * @param tenantId 租户id
     * @return 还款流水号
     */
    List<String> selectByLoanIdAndCustomerId(@Param(value="loanId") String loanId,
                                             @Param(value="customerId") String customerId,
                                             @Param(value="tenantId") String tenantId);

    /**
     * 按还款流水号查询还款流水预订单映射信息
     * 批次使用
     *
     * @param seqNoList
     * @return 还款流水映射
     */
    List<String> selectBySeqNoListForBatch(List<String> seqNoList);

    /**
     * 按还款流水号查询还款流水预订单映射信息
     *
     * @param seqNoList
     * @return 还款流水映射
     */
    List<String> selectBySeqNoList(@Param("seqNoList") List<String> seqNoList, @Param("customerId") String customerId,
                                   @Param("tenantId") String tenantId);

    /**
     * 根据创建时间批量获取
     * @param startTime
     * @return
     */
    List<TlPaymentMapping> selectByUpdateTime(@Param("startTime") String startTime);


    /**
     * 查询订单最近还款流水号
     * @param loanId
     * @param customerId
     * @param tenantId
     * @return
     */
    String findLastByCustomerIdAndLoanId(@Param(value="loanId") String loanId,
                                         @Param(value="customerId") String customerId,
                                         @Param(value="tenantId") String tenantId);
}